﻿using System;
using System.Linq;
using System.Reflection;


namespace DataAssociations.Repository
{
    public static class Reflectioner
    {
        public static Type[] FindImplementationsOfType<T>(Assembly assembly)
        {
            return assembly.GetTypes().
                Where(x => typeof (T).IsAssignableFrom(x) 
                    && x.IsClass && x.IsAbstract == false).ToArray();
        }

        public static Type[] FindSubClasses<T>(Assembly assembly)
        {
            return assembly.GetTypes().
                Where(x => x.IsSubclassOf(typeof(T))).ToArray();
        }
    }
}
